﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Coldairarrow.Business.Goods;
using Coldairarrow.Entity.Goods;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;

namespace Coldairarrow.Api.Controllers.backstage
{
        [Route("/backstage/[controller]/[action]")]
        public class BKS_BannerController : BaseApiController
        {
            #region DI

            public BKS_BannerController(IBTB_BannerBusiness bTB_BannerBus)
            {
                _bTB_BannerBus = bTB_BannerBus;
            }

            IBTB_BannerBusiness _bTB_BannerBus { get; }

        #endregion
        /// <summary>
        /// 限时特惠轮播图分页列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<PageResult<BTB_Banner>> GetPreferentialListAsync(PageInput<BTB_Banner> input)
        {
            return await _bTB_BannerBus.GetPreferentialListAsync(input);
        }

        /// <summary>
        /// 首页轮播图分页列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<PageResult<BTB_Banner>> GetHomeListAsync(PageInput<ConditionDTO> input)
        {
            return await _bTB_BannerBus.GetHomeListAsync(input);
        }

        /// <summary>
        /// 查询指定的首页轮播图
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List< BTB_Banner>> GetTheData(IdInputDTO input)
        {
            return await _bTB_BannerBus.GetTheDataAsync(input.id);
        }

        #region 提交
        /// <summary>
        /// 添加或修改轮播图
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveData(BTB_Banner data)
        {
            if (data.id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bTB_BannerBus.AddDataAsync(data);
            }
            else
            {
                await _bTB_BannerBus.UpdateDataAsync(data);
            }
        }
        /// <summary>
        /// 删除指定轮播图
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _bTB_BannerBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}
